import static org.junit.Assert.*;


import org.junit.Test;


public class HandTest {
	

	@Test
	public void testEvaluateBestHand_4Values1Suit_1CardBadugi() {
		Hand testHand1 = new Hand();
		Card [] cards = new Card [4];
		Card [] result = new Card [1];
				
		
		try{
			cards[0]=new Card(2,1);
			cards[1]=new Card(3,1);
			cards[2]=new Card(4,1);
			cards[3]=new Card(5,1);
		}
		catch(BadugiException e){
			
		}
		
		result[0]=cards[0];

		for(int i=0; i<=3; i++){
			testHand1.add(cards[i]);
		}
		
		int size = testHand1.evaluateBestHand();
		
	    assertTrue(size==1);

	    for(int i=0; i<size; i++){
	    	assertTrue(testHand1.getCard(i)==result[i]);
	    }
		
	}

	@Test
	public void testEvaluateBestHand_4Values2Suits_2CardBadugi() {
		Hand testHand1 = new Hand();
		Card [] cards = new Card [4];
		Card [] result = new Card [2];
		
		try{
			cards[0]=new Card(3,2);
			cards[1]=new Card(2,1);
			cards[2]=new Card(4,1);
			cards[3]=new Card(5,2);
		}
		catch(BadugiException e){
			
		}

		result[0]=cards[1];
		result[1]=cards[0];
		
		for(int i=0; i<=3; i++){
			testHand1.add(cards[i]);
		}
		
		int size = testHand1.evaluateBestHand();
		
	    assertTrue(size==2);
		
	    for(int i=0; i<size; i++){
	    	assertTrue(testHand1.getCard(i)==result[i]);
	    }
		
	}
	
	public void testCompareTo_2HandsOfDifferentSize_SecondWins(){
		
		Hand testHand1 = new Hand();
		Hand testHand2 = new Hand();
		Card [] cards = new Card [4];
		Card [] cards2 = new Card [4];
		
		try{
			cards[0]=new Card(3,2);
			cards[1]=new Card(2,1);
			cards[2]=new Card(4,1);
			cards[3]=new Card(5,2);
			
			cards2[0]=new Card(3,2);
			cards2[1]=new Card(2,1);
			cards2[2]=new Card(4,1);
			cards2[3]=new Card(5,3);
			
		}
		catch(BadugiException e){
			
		}
		
		for(int i=0; i<=3; i++){
			testHand1.add(cards[i]);
			testHand2.add(cards2[i]);
		}
		
		assertTrue(testHand2.compareTo(testHand1)>0);
	}
	
	
	
}
